'use strict';

/* Controllers */

angular.module('myApp.controllers',[])
  	.controller('MyCtrl1', ['$scope', function($scope) {

  	}])
  	.controller('MyCtrl2', ['$scope', function($scope) {

  	}])
  	.controller('AccordionDemoCtrl', function($scope, $timeout, ngTableParams) {
		  $scope.oneAtATime = false;
      $scope.jobsDownloadingFiles = [
        {
          title: 'Polling to download file',
          status: true,
          content: [
            {'jobName':'Job 1', 'priority':10},
            {'jobName':'Job 2', 'priority':10},
            {'jobName':'Job 3', 'priority':10}
          ]
        }
      ];
      $scope.jobsWaitingToBeLoaded = [
        {
          title: 'In queue to be loaded',
          status: true,
          content: [
            {'jobName':'Job 4', 'priority':10},
            {'jobName':'Job 5', 'priority':10}
          ]
        }
      ];
      $scope.jobsCurrentlyRunning = [
        {
          title: 'Currently running',
          status: true,
          content: [
            {'jobName':'Job 6', 'priority':10},
            {'jobName':'job 7', 'priority':10},
            {'jobName':'job 8', 'priority':10},
            {'jobName':'job 9', 'priority':10},
            {'jobName':'job 10', 'priority':10}
          ]
        }
      ];
      $scope.jobsBeingHeld = [
        {
          title: 'Jobs being held',
          status: true,
          content: [
            {'jobName':'job 11', 'priority':10},
            {'jobName':'job 12', 'priority':10},
            {'jobName':'job 13', 'priority':10},
            {'jobName':'job 14', 'priority':10}
          ]
        }
      ];

      $scope.tableParams = new ngTableParams({
        page: 1,            // show first page
        count: 2           // count per page
      }, {
        counts: [], // hide page counts control
        total: $scope.jobsDownloadingFiles[0].content.length, // length of data
        getData: function($defer, params) {
          $defer.resolve($scope.jobsDownloadingFiles[0].content.slice((params.page() - 1) * params.count(), params.page() * params.count()));
        }
      });

      $scope.tableParams2 = new ngTableParams({
        page: 1,            // show first page
        count: 2           // count per page
      }, {
        counts: [], // hide page counts control
        total: $scope.jobsWaitingToBeLoaded[0].content.length, // length of data
        getData: function($defer, params) {
          $defer.resolve($scope.jobsWaitingToBeLoaded[0].content.slice((params.page() - 1) * params.count(), params.page() * params.count()));
        }
      });

      $scope.tableParams3 = new ngTableParams({
        page: 1,            // show first page
        count: 2           // count per page
      }, {
        counts: [], // hide page counts control
        total: $scope.jobsCurrentlyRunning[0].content.length, // length of data
        getData: function($defer, params) {
          $defer.resolve($scope.jobsCurrentlyRunning[0].content.slice((params.page() - 1) * params.count(), params.page() * params.count()));
        }
      });

      $scope.tableParams4 = new ngTableParams({
        page: 1,            // show first page
        count: 2           // count per page
      }, {
        counts: [], // hide page counts control
        total: $scope.jobsBeingHeld[0].content.length, // length of data
        getData: function($defer, params) {
          $defer.resolve($scope.jobsBeingHeld[0].content.slice((params.page() - 1) * params.count(), params.page() * params.count()));
        }
      });
    })







  .controller('AccordionDemoCtrlold', function($scope, $timeout, ngTableParams) {
    

  $scope.groups = [
    {
      title: 'Dynamic Group Header - 1',
      content: 'Dynamic Group Body - 1'
    },
    {
      title: 'Dynamic Group Header - 2',
      content: 'Dynamic Group Body - 2'
    }
  ];

  $scope.items = ['Item 1', 'Item 2', 'Item 3'];

  $scope.addItem = function() {
    var newItemNo = $scope.items.length + 1;
    $scope.items.push('Item ' + newItemNo);
  };

  $scope.status = {
    isFirstOpen: true,
    isFirstDisabled: false
  };

      $scope.data = [{name: "Moroni", age: 50},
                {name: "Tiancum", age: 43},
                {name: "Jacob", age: 27},
                {name: "Nephi", age: 29},
                {name: "Enos", age: 34},
                {name: "Tiancum", age: 43},
                {name: "Jacob", age: 27},
                {name: "Nephi", age: 29},
                {name: "Enos", age: 34},
                {name: "Tiancum", age: 43},
                {name: "Jacob", age: 27},
                {name: "Nephi", age: 29},
                {name: "Enos", age: 34},
                {name: "Tiancum", age: 43},
                {name: "Jacob", age: 27},
                {name: "Nephi", age: 29},
                {name: "Enos", age: 34}];
        
        var data = [{name: "Moroni", age: 50},
                        {name: "Tiancum", age: 43},
                        {name: "Jacob", age: 27},
                        {name: "Nephi", age: 29},
                        {name: "Enos", age: 34},
                        {name: "Tiancum", age: 43},
                        {name: "Jacob", age: 27},
                        {name: "Nephi", age: 29},
                        {name: "Enos", age: 34},
                        {name: "Tiancum", age: 43},
                        {name: "Jacob", age: 27},
                        {name: "Nephi", age: 29},
                        {name: "Enos", age: 34},
                        {name: "Tiancum", age: 43},
                        {name: "Jacob", age: 27},
                        {name: "Nephi", age: 29},
                        {name: "Enos", age: 34}];

            $scope.tableParams = new ngTableParams({
                page: 1,            // show first page
                count: 10           // count per page
            }, {
                total: data.length, // length of data
                getData: function($defer, params) {
                    $defer.resolve(data.slice((params.page() - 1) * params.count(), params.page() * params.count()));
                }
            });          
    $scope.list1 = [{'title': 'Lolcat Shirt'},{'title': 'Cheezeburger Shirt'},{'title': 'Buckit Shirt'}];
    $scope.list2 = [{'title': 'Zebra Striped'},{'title': 'Black Leather'},{'title': 'Alligator Leather'}];
    $scope.list3 = [{'title': 'iPhone'},{'title': 'iPod'},{'title': 'iPad'}];

    $scope.list4 = [];

    $scope.hideMe = function() {
      return $scope.list4.length > 0;
    }
  });





